<!--
* description: 变更网点弹出框（网点，责任网点，意向网点多选）
* author: dxuem
* createdDate: 2019-10-09
-->
<template>
  <section class="carTypeConfig">
    <el-dialog v-dialogDrag
      title="网点选择"
      :visible.sync="curPopupsVisible"
      width="1000px"
      center
      @close="sendCode"
      :close-on-click-modal="false"
      :append-to-body="true"
    >
      <dialogHeader
        slot="title"
        :title="'网点选择'"
        :styleType="$store.state.app.dialogType"
      ></dialogHeader>
      <one-table-template
        ref="multipleTable"
        :dynamicButtons="tableButtons"
        :dynamicComponents="tableComponents"
        :dynamicApiConfig="apiConfig"
        :dynamicTableCols="tableCols"
        :dynamicFormFields="formField"
        :dynamicIsShowSelect="isMul"
      />
    </el-dialog>
  </section>
</template>
<script>
import { oneTableWithViewTemplateMixins } from "@/components/mixins/oneTableWithViewTemplateMixins";
import { valueObjectMixins } from "@/components/mixins/valueObjectMixins";
import { crmApis } from "@/api/apiList/crm";
import OneTableTemplate from "@/components/crm/commonComponents/crmPopupsOneTable";

export default {
  // 组件混入对象：{data[listQuery] methods[queryTable]}
  mixins: [oneTableWithViewTemplateMixins, valueObjectMixins],
  components: {
    OneTableTemplate,
    dialogHeader: () => import("@/components/dialogHeader") //弹窗标题
  },
  data() {
    return {
      // 网格查询API配置对象
      apiConfig: crmApis.mdmOrgdlrQueryByPage, //经销商查询
      // 动态组件-按钮
      tableButtons: [
        {
          compKey: "btnKey1",
          type: "primary",
          size: "small",
          clickEvent: () => this.queryTable(1),
          text: "查询",
          position: "top"
        },
        {
          compKey: "btnKey2",
          type: "primary",
          size: "small",
          clickEvent: () => this.sendCode(this.codeField, "dlrShortName"),
          text: "确认",
          position: "bottom"
        },
        {
          compKey: "btnKey3",
          type: "",
          size: "small",
          clickEvent: () => this.reset(),
          text: "重置",
          position: "top"
        }
      ],
      // 动态组件-查询条件
      tableComponents: [
        // 显示组件
        {
          compKey: "compKey1",
          labelName: "网点简称",
          codeField: "dlrShortName",
          component: () => import("@/components/crm/textbox/crmTextInput"),
          type: "inputText",
          isMust: true
        },
        {
          compKey: "compKey2",
          labelName: "网点品牌",
          codeField: "carBrandCode",
          textField: "carBrandCn",
          lookuptype: crmApis.mdmCarBrandQueryByPage,
          component: () => import("@/components/crm/lookupValue/apiDropList"),
          type: "dropdownList",
          isMust: true,
          isMul: false
        },
        {
          compKey: "compKey3",
          labelName: "网点类别",
          codeField: "orgType",
          lookuptype: "DB0062",
          component: () => import("@/components/org/LookupValue"),
          type: "dropdownList",
          isMust: true,
          isMul: false
        },

        {
          compKey: "compKey4",
          labelName: "省份",
          codeField: "provinceId",
          textField: "provinceName",
          lookuptype: crmApis.mdmOrgProvinceQueryFindAll,
          changeCode: this.changeCityByProvince,
          isRequire: false,
          component: () =>
            import("@/components/crm/lookupValue/singleDropList"),
          isMust: true,
          isMul: false
        },
        {
          compKey: "provinceId",
          labelName: "城市",
          codeField: "cityId",
          textField: "cityName",
          isRequire: false,
          isMust: true,
          isMul: false,
          lookuptype: crmApis.mdmOrgCityQueryFindAll,
          changeCodeArray: [{ changCode: "provinceId" }],
          component: () => import("@/components/crm/lookupValue/secondDropList")
        },
        {
          compKey: "compKey5",
          labelName: "网点状态",
          codeField: "dlrStatus",
          lookuptype: "DB0066",
          component: () => import("@/components/org/LookupValue"),
          type: "dropdownList",
          isMust: true,
          isMul: false
        }
      ],
      // 动态生成网格列
      tableCols: [
        {
          prop: "dlrCode",
          label: "网点编码",
          width: null,
          align: "center"
        },
        {
          prop: "dlrId",
          label: "网点ID",
          width: null,
          hidden: true,
          align: "center"
        },
        {
          prop: "dlrShortName",
          label: "网点简称",
          width: 200,
          align: "center"
        },
        {
          prop: "carBrandCn",
          label: "网点品牌",
          width: 140,
          align: "center"
        },
        {
          prop: "orgTypeName",
          label: "网点类型",
          width: null,
          align: "center"
        },
        {
          prop: "dlrStatusName",
          label: "网点状态",
          width: null,
          align: "center"
        },
        {
          prop: "provinceName",
          label: "省份",
          width: null,
          align: "center"
        },
        {
          prop: "cityName",
          label: "城市",
          width: null,
          align: "center"
        },
        {
          prop: "dlrFullName",
          label: "网店全称",
          width: 200,
          hidden: true,
          align: "center"
        },
        {
          prop: "carBrandCode",
          label: "",
          width: null,
          align: "center",
          hidden: true
        }
      ],
      //表单查询数据（查询条件）
      formField: {
        carBrandCode: "",
        cityId: "",
        dlrShortName: "",
        dlrStatus: "",
        isEnable: "1",
        orgType: "",
        provinceId: "",

      },
      handleTableRowData: {
        value: this.codeField,
        text: "dlrShortName"
      }
    };
  },
  mounted() {
    this.formField.isEnable = "1";
    // if(this.$store.getters.orgInfo.ORG_TYPE&&this.$store.getters.orgInfo.ORG_TYPE=='1'){//ORG_TYPE为0是主机厂，为1是经销商
    //   this.formField.specCurAuthorOnly='1';//此字段用于筛选网点
    // }
  },
  methods: {}
};
</script>
